package com.cheng.example.atguigu.design_pattern.decorator;

/*
 * @author 程帅
 * @createTime: 2020/10/17 18:12
 * @Created: with IntelliJ IDEA.
 */

//Decorator装饰者类
public class Decorator extends Drink {

    private Drink obj;

    public Decorator(Drink obj) {
        this.obj = obj;
    }

    @Override
    public float cost() {
        //getPrice 自己的价格
        return super.getPrice()+obj.cost();
    }

    @Override
    public String getDes() {
        //obj.getDes() 输出被装饰者的信息
        return des + " " + getPrice() + " && " + obj.getDes();
    }
}
